package chapter03

import org.apache.spark.{SparkConf, SparkContext}

object Test10_glom {
  def main(args: Array[String]): Unit = {
    val conf = new SparkConf().setMaster("local[*]").setAppName("glom")
    val sc = new SparkContext(conf)
    val value = sc.makeRDD(List(1, 2, 3, 4, 5, 6, 7, 8), 3)
    val value1 = value.glom()
    //取每个分区的第一个元素
    println(value1.map(e=>e(0)).collect().toList)
    //计算每个分区的最大值 然后计算和
    val d = value1.map(e => e.max).sum().toInt
    println(d)
  }
}
